o regression

- saving scripts (playback and state scripts) are now prepended with
	info about what type of script it is. in practice it has proved
	useful to know this from a glance, rather than opening up the file.

o gopher2600
    - playing back recordings is now more intuitive
    - removed option to specify the filename that a new recording will
	save to but I think that's acceptable.
This commit is contained in:
steve 2019-11-12 23:34:44 +00:00
parent 17b5c599f2
commit cc8c14f0ae
5 changed files with 23 additions and 28 deletions

View file

@ -81,7 +81,6 @@ func play(mf *magicflags.MagicFlags) bool {
scaling := mf.SubModeFlags.Float64("scale", 3.0, "television scaling")
stable := mf.SubModeFlags.Bool("stable", true, "wait for stable frame before opening display")
record := mf.SubModeFlags.Bool("record", false, "record user input to a file")
recording := mf.SubModeFlags.String("recording", "", "the file to use for recording/playback")
if mf.SubParse() != magicflags.ParseContinue {
return false
@ -89,26 +88,21 @@ func play(mf *magicflags.MagicFlags) bool {
switch len(mf.SubModeFlags.Args()) {
case 0:
if *recording == "" {
fmt.Println("* 2600 cartridge required")
return false
}
fallthrough
fmt.Println("* 2600 cartridge required")
return false
case 1:
cartload := cartridgeloader.Loader{
Filename: mf.SubModeFlags.Arg(0),
Format: *cartFormat,
}
err := playmode.Play(*tvType, float32(*scaling), *stable, *recording, *record, cartload)
err := playmode.Play(*tvType, float32(*scaling), *stable, *record, cartload)
if err != nil {
fmt.Printf("* %s\n", err)
return false
}
if *record {
fmt.Println("! recording completed")
} else if *recording != "" {
fmt.Println("! playback completed")
}
default:
fmt.Printf("* too many arguments for %s mode\n", mf.Mode)

View file

@ -21,9 +21,20 @@ func uniqueFilename(cartload cartridgeloader.Loader) string {
}
// Play sets the emulation running - without any debugging features
func Play(tvType string, scaling float32, stable bool, transcript string, newRecording bool, cartload cartridgeloader.Loader) error {
func Play(tvType string, scaling float32, stable bool, newRecording bool, cartload cartridgeloader.Loader) error {
var transcript string
// if supplied cartridge name is actually a playback file then set
// transcript and dump cartridgeLoader information
if recorder.IsPlaybackFile(cartload.Filename) {
return errors.New(errors.PlayError, "specified cartridge is a playback file. use -recording flag")
// do not allow this if a new recording has been requested
if newRecording {
return errors.New(errors.PlayError, "cannot make a new recording using a playback file")
}
transcript = cartload.Filename
cartload = cartridgeloader.Loader{}
}
playtv, err := sdlplay.NewSdlPlay(tvType, scaling, nil)
@ -36,23 +47,13 @@ func Play(tvType string, scaling float32, stable bool, transcript string, newRec
return errors.New(errors.PlayError, err)
}
// create default recording file name if no name has been supplied
if newRecording && transcript == "" {
n := time.Now()
timestamp := fmt.Sprintf("%04d%02d%02d_%02d%02d%02d", n.Year(), n.Month(), n.Day(), n.Hour(), n.Minute(), n.Second())
transcript = fmt.Sprintf("recording_%s_%s", cartload.ShortName(), timestamp)
}
// note that we attach the cartridge in three different branches below,
// depending on
if newRecording {
// new recording requested
// no transcript name given so we must generate a suitable default
if transcript == "" {
transcript = uniqueFilename(cartload)
}
transcript = uniqueFilename(cartload)
rec, err := recorder.NewRecorder(transcript, vcs)
if err != nil {

View file

@ -185,7 +185,7 @@ func (reg *FrameRegression) regress(newRegression bool, output io.Writer, msg st
if reg.State {
// create a unique filename
reg.stateFile = uniqueFilename(reg.CartLoad)
reg.stateFile = uniqueFilename("state", reg.CartLoad)
// check that the filename is unique
nf, _ := os.Open(reg.stateFile)

View file

@ -168,7 +168,7 @@ func (reg *PlaybackRegression) regress(newRegression bool, output io.Writer, msg
// regressionScripts directory
if newRegression {
// create a unique filename
newScript := uniqueFilename(plb.CartLoad)
newScript := uniqueFilename("playback", plb.CartLoad)
// check that the filename is unique
nf, _ := os.Open(newScript)

View file

@ -7,11 +7,11 @@ import (
"time"
)
// create a unique filename from a CatridgeLoader instance
func uniqueFilename(cartload cartridgeloader.Loader) string {
// create a unique filename from a CatridgeLoader instance. used when saving
// scripts into regressionScripts directory
func uniqueFilename(prepend string, cartload cartridgeloader.Loader) string {
n := time.Now()
timestamp := fmt.Sprintf("%04d%02d%02d_%02d%02d%02d", n.Year(), n.Month(), n.Day(), n.Hour(), n.Minute(), n.Second())
newScript := fmt.Sprintf("%s_%s", cartload.ShortName(), timestamp)
newScript := fmt.Sprintf("%s_%s_%s", prepend, cartload.ShortName(), timestamp)
return paths.ResourcePath(regressionScripts, newScript)
}