2022-02-21 22:05:53 +00:00
|
|
|
package izapple2
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/ivanizag/izapple2/screen"
|
|
|
|
)
|
|
|
|
|
|
|
|
type apple2Tester struct {
|
|
|
|
a *Apple2
|
|
|
|
terminateCondition func(a *Apple2) bool
|
|
|
|
}
|
|
|
|
|
2024-01-06 20:48:23 +00:00
|
|
|
func makeApple2Tester(model string, overrides *configuration) (*apple2Tester, error) {
|
|
|
|
config, err := getConfigurationFromModel(model, overrides)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
config.set(confSpeed, "full")
|
|
|
|
a, err := configure(config)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
2022-02-21 22:05:53 +00:00
|
|
|
|
|
|
|
var at apple2Tester
|
|
|
|
a.addTracer(&at)
|
2024-01-06 20:48:23 +00:00
|
|
|
return &at, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (at *apple2Tester) connect(a *Apple2) {
|
|
|
|
at.a = a
|
2022-02-21 22:05:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (at *apple2Tester) inspect() {
|
|
|
|
if at.terminateCondition(at.a) {
|
|
|
|
at.a.SendCommand(CommandKill)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (at *apple2Tester) run() {
|
|
|
|
at.a.Run()
|
|
|
|
}
|
|
|
|
|
|
|
|
func (at *apple2Tester) getText() string {
|
|
|
|
return screen.RenderTextModeString(at.a, false, false, false, at.a.isApple2e)
|
|
|
|
}
|
2022-03-08 19:11:26 +00:00
|
|
|
|
|
|
|
func (at *apple2Tester) getText80() string {
|
|
|
|
return screen.RenderTextModeString(at.a, true, false, false, at.a.isApple2e)
|
|
|
|
}
|