stella icon indicating copy to clipboard operation
stella copied to clipboard

Input State batch file

Open SpiceWare opened this issue 7 years ago • 10 comments

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. ...

SpiceWare avatar Aug 23 '17 21:08 SpiceWare

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.

sa666666 avatar Aug 24 '17 00:08 sa666666

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

thrust26 avatar Aug 24 '17 06:08 thrust26

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.

DirtyHairy avatar Aug 24 '17 08:08 DirtyHairy

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

thrust26 avatar Aug 24 '17 08:08 thrust26

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.

SpiceWare avatar Aug 24 '17 15:08 SpiceWare

What frame command do you mean?

thrust26 avatar Aug 24 '17 15:08 thrust26

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.

SpiceWare avatar Aug 24 '17 16:08 SpiceWare

Ah, I thought you meant the command line.

thrust26 avatar Aug 24 '17 16:08 thrust26

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.

SpiceWare avatar Aug 24 '17 16:08 SpiceWare

I think could be further enhanced, e.g.

  • recording this file during play
  • fast forward to frame n (or for n frames)
  • create savestate
  • load savestate (initial state)
  • ...

thrust26 avatar Aug 25 '17 08:08 thrust26