Redo main cycle

This commit is contained in:
romych committed 2026-03-22 14:27:14 +03:00
1 parent c1616dfbd6
commit a74841b048
11 files changed
+434 -139

No files matched your search

+39 -6
View File
@@ -10,21 +10,21 @@ import (
const defaultMonitorFile = "rom/MON_v5.bin"
const defaultCPMFile = "rom/CPM_v5.bin"
const DefaultDebufPort = 10000
const confFile = "okemu.yml"
type OkEmuConfig struct {
LogFile string `yaml:"logFile"`
LogLevel string `yaml:"logLevel"`
MonitorFile string `yaml:"monitorFile"`
CPMFile string `yaml:"cpmFile"`
FDC FDCConfig `yaml:"fdc"`
FDC []FDCConfig `yaml:"fdc"`
Debugger DebuggerConfig `yaml:"debugger"`
}
type FDCConfig struct {
AutoLoadB bool `yaml:"autoLoadB"`
AutoLoadC bool `yaml:"autoLoadC"`
FloppyB string `yaml:"floppyB"`
FloppyC string `yaml:"floppyC"`
AutoLoad bool `yaml:"autoLoad"`
AutoSave bool `yaml:"autoSave"`
FloppyFile string `yaml:"floppyFile"`
}
type DebuggerConfig struct {
@@ -54,7 +54,6 @@ func LoadConfig() {
// usage()
//}
// confFile := args[2]
confFile := "okemu.yml"
conf := OkEmuConfig{}
data, err := os.ReadFile(confFile)
@@ -96,3 +95,37 @@ func setDefaultConf(conf *OkEmuConfig) {
conf.Debugger.Port = DefaultDebufPort
}
}
func (c *OkEmuConfig) Clone() *OkEmuConfig {
fds := make([]FDCConfig, 2)
for n, fd := range c.FDC {
fds[n].FloppyFile = fd.FloppyFile
fds[n].AutoLoad = fd.AutoLoad
fds[n].AutoSave = fd.AutoSave
}
return &OkEmuConfig{
LogFile: c.LogFile,
LogLevel: c.LogLevel,
MonitorFile: c.MonitorFile,
CPMFile: c.CPMFile,
FDC: fds,
Debugger: DebuggerConfig{
Enabled: c.Debugger.Enabled,
Host: c.Debugger.Host,
Port: c.Debugger.Port,
},
}
}
func (c *OkEmuConfig) Save() {
data, err := yaml.Marshal(c)
if err != nil {
log.Errorf("config error: %v", err)
}
err = os.WriteFile(confFile, data, 0600)
if err != nil {
log.Errorf("save config file: %v", err)
}
}